/*
 *  $Id: Base.cs 898 2009-11-28 16:12:26Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Affects {
    /// <summary>
    /// Абстрактный эффект для обработки событий
    /// </summary>
    public abstract class Event<T>: Affect {
        public readonly T Handler;
        public readonly AffectSummaryType SumTypes;

        public Event(T handler, AffectSummaryType sumTypes) {
            Handler = handler;
            SumTypes = sumTypes;
        }

        public override void SetAffect() {
            base.SetAffect();
            if ((SumTypes & AffectSummaryType.Local) != 0)
                SetEvent(LocalSummary);
            if ((SumTypes & AffectSummaryType.Global) != 0)
                SetEvent(GlobalSummary);
            if ((SumTypes & AffectSummaryType.Enemy) != 0)
                SetEvent(EnemySummary);
        }
        public override void ResetAffect() {
            base.ResetAffect();
            if ((SumTypes & AffectSummaryType.Local) != 0)
                ResetEvent(LocalSummary);
            if ((SumTypes & AffectSummaryType.Global) != 0)
                ResetEvent(GlobalSummary);
            if ((SumTypes & AffectSummaryType.Enemy) != 0)
                ResetEvent(EnemySummary);
        }

        public abstract void SetEvent(AffectSummary summary);
        public abstract void ResetEvent(AffectSummary summary);
    }
}